﻿using SimpleUnitity.Database.Config;
using SimpleUnitity.Database.Extension;
using SimpleUnitity.Database;
using SimpleUnitity.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Configuration;
using SimpleUnitity.Threading;

namespace SimpleUnitity.DbTesting
{
    class Program
    {
        static void Main(string[] args)
        {
            DelayCaller c1 = new DelayCaller();
            c1.OnTimeout += (sender, e) => { Console.WriteLine("{0:HH:mm:ss.ms}\tc1   等待连接超时", DateTime.Now); };
            c1.Delay(1);

            DelayCaller c2 = new DelayCaller();
            c2.OnTimeout += (sender, e) => { Console.WriteLine("{0:HH:mm:ss.ms}\tc2   等待连接超时......", DateTime.Now); };
            c2.Delay(4);

            DelayCaller c3 = new DelayCaller();
            c3.OnTimeout += (sender, e) => { Console.WriteLine("{0:HH:mm:ss.ms}\tc3   等待连接超时......", DateTime.Now); };
            c3.Delay(2);


            Console.WriteLine("{0:HH:mm:ss.ms}\txxxxxxxxx.....end", DateTime.Now);

            //var section = (DbProviderSection)ConfigurationManager.GetSection(ConfigurationManager.AppSettings["DefaultDatabaseProvider"]);
            //var connStringName = ConfigurationManager.AppSettings["DefaultConnectionString"];
            //var dbtools = section.CreateDbTool(ConfigurationManager.ConnectionStrings[connStringName].ConnectionString);

            //LogHelper.InitLog(ELogLevel.All);

            //var db = new DataHelper(dbtools, new PerTimeFileLog("d:/log/test", PerTimeType.Day));


            //var res = db.Query("select * from user");
            //if (res.Count > 0)
            //{
            //    var user = res[0];
            //    foreach (var field in res[0].GetFields())
            //    {
            //        Console.WriteLine("{0,15}\t: {1}", field, res[0][field]);
            //    }



            //    int rowcount = db.ExecuteNonQuery("update user set email = @0 where id = @1", "test@email.com", 1);
            //    Console.WriteLine(rowcount);
            //    Console.WriteLine("\n-------------------------------------------------\n");
            //}

            Console.ReadLine();
        }
    }
}